/*
 * AGENT SHERPA
 *  
 * Assignement 2 of the Agent Oriented Software Engineering Course
 * M.Sc. in Advanced Software Engineering (Part-time)
 * University College Dublin www.ucd.ie
 *
 * Copyright (c) 2007 Chris Walsh, Aidan Morrisy and Iain Hull.
 * All rights reserved.
 */

package org.agentsherpa;

import java.util.Map;

import com.agentfactory.platform.interfaces.Perceptor;

/**
 *
 * @author  Aidan
 */
public class AgentsAlivePerceptor extends Perceptor {
    
    public void perceive() {
       
        ControlAgentModule module = (ControlAgentModule)getModuleByName("controlagentmodule");
       if (module == null) {
            System.out.println("AgentsAlivePerceptor: cannot find module");
            return;
        }
        
        if (module.getAgents() == null) {
            System.out.println("AgentsAlivePerceptor: No Agents Alive at Present");
        }else{
            Map<String, String> agents = module.getAgents();
            for (String agent : agents.keySet()){
                adoptBelief("BELIEF(alive(agentID(" + agent + "," + agents.get(agent)+ ")))");
                System.out.println("Agent added :" + agent + "," + agents.get(agent));     
            }
        }
    }
}
